Comment: Win32 Application Setup Project
 
 
 
[DEFINE REGION: Define Setup Globals]
Comment: Define Setup Components
Define Component: New Project
 
Comment: Initialize Setup Globals
Get System Setting Windows NT Kernel (NT4, 2000, XP, 2003, Vista, 2008, 7, 2008 R2, 8, 2012, 8.1, 2012 R2, 10, 2016) into ISNT
Get Folder Location System->Program Files Directory into PROGRAMFILES
Get Common Folder Location System->Program Files Directory into COMMONFILES
Get Common Folder Location Start Menu->Programs Group into SHORTCUTFILESALL
Get Folder Location Start Menu->Programs Group into SHORTCUTFILES
if Variable SHORTCUTFILESALL Equals 
  Set Variable SHORTCUTFILESALL to $SHORTCUTFILES$
end
Get Folder Location System->Desktop Directory into DESKTOPDIR
Get Folder Location System->Windows Directory into WINDIR
Get Folder Location System->System Directory into WINSYSDIR
Get Folder Location Taskbar->Quick Launch Directory into QUICKLAUNCHDIR
Get Folder Location WWW->WWWRoot into WWWROOTDIR
Set Variable MY_FOLDER_NAME to Test Folder
Set Variable SECONDARY_TARGETDIR to $PROGRAMFILES$\$TITLE$\$MY_FOLDER_NAME$
[END REGION]
 
[DEFINE REGION: Setup User Interview]
 
label: Destination Directory
Set Variable CONTINUE_LOOP to TRUE
while Variable CONTINUE_LOOP Equals TRUE loop
  Display Dialog: destination, wait for dialog to return (modal)
   
  if Variable WIZARD Equals BROWSE_FOR_ADRDATA
    Set Variable USER_FOLDER to 
    Browse for a folder path into variable USER_FOLDER, with caption Browse for $MY_FOLDER_NAME$ folder 
     
    if Variable USER_FOLDER not Equals 
      Comment: Check for trailing slash
      Set Variable SLASH_CHECKER to 
      Parse String $USER_FOLDER$ into Variables  and SLASH_CHECKER (Split at last occurrence of pattern)
      if Variable SLASH_CHECKER Equals 
        Set Variable SECONDARY_TARGETDIR to $USER_FOLDER$$MY_FOLDER_NAME$
      else
        Set Variable SECONDARY_TARGETDIR to $USER_FOLDER$\$MY_FOLDER_NAME$
      end
    end
  else
    Set Variable CONTINUE_LOOP to FALSE
  end
wend
 
MessageBox: , SECONDARY_TARGETDIR = $SECONDARY_TARGETDIR$$NEWLINE$$NEWLINE$TARGETDIR = $TARGETDIR$
